//
//  UITextField+DHKuaiYiAdditions.m
//  DHKuaiYi
//
//  Created by Cedric Zheng on 15/11/2016.
//  Copyright © 2016 30-陈辉华. All rights reserved.
//

#import "UITextField+DHKuaiYiAdditions.h"
#import <Masonry.h>

@implementation UITextField (DHKuaiYiAdditions)

- (void)setTextFieldLeftImageWithImageNamed:(NSString *)imageName {
    
//    UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 16, 20)];
//    UIImageView *imageView = [[UIImageView alloc] init];
//    imageView.image = [UIImage imageNamed:imageName];
    
    UIImageView *leftImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
    [self addSubview:leftImgView];
    
    
    //约束imageView
//    [leftImgView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(leftView).offset(5);
//        make.right.mas_equalTo(leftView);
//        make.top.mas_equalTo(leftView);
//        make.bottom.mas_equalTo(leftView.mas_bottom);
        
//    }];
    
    self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    self.leftViewMode = UITextFieldViewModeAlways;
    self.leftView = leftImgView;
}

@end
